home *** CD-ROM | disk | FTP | other *** search
- Path: diku.dk!null
- From: null@diku.dk (Niels Ull Jacobsen)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ performance
- Date: 14 Jan 1996 13:26:31 GMT
- Organization: Department of Computer Science, U of Copenhagen
- Sender: null@tyr.diku.dk
- Message-ID: <4db0a7$60d@odin.diku.dk>
- References: <4d3v93$rf9@news1.usa.pipeline.com>
- NNTP-Posting-Host: odin.diku.dk
- X-Newsreader: NN version 6.5.0 #13
-
- grantp@usa.pipeline.com(Pete) writes:
-
- >On Jan 11, 1996 18:25:17 in article <C++ performance>,
- >'christ@lexis-nexis.com (Chris Tilton)' wrote:
- >
- >
- >>What (if any) rules of thumb/tricks of the trade exist
- >>for enhancing the performance of a program? I discovered
- >>how to make a small function 'inline' and was curious
- >>of what else exists to enhance execution speed.
-
- /O2 :-)
-
- >The best rule of thumb is to analyze your algorithms and improve
- >them to the best of your ability. Use a profiler to help determine
- >where your program spends most of its time and concentrate on
- >speeding up those portions. Inlining and other 'tricks' applied
- >everywhere without discretion typically produce only minor gains.
-
- This is, of course, the best advice.
-
- Another typical pitfall of C++ is accidently invoking copy
- constructors. *Always* implement a copy constructor in your objects,
- unless you *really* want the default one. If you make it private, your
- compiler will tell you most of the time when you accidently invoke
- it. If you leave out the implementation, your linker will tell you the
- rest.
-
- In some environments, it will pay to make large local variables static
- (unless you're worried about reentrancy, of course).
-
- Also, once you have found the *really* time-critical pieces of code,
- turn on the "assembly listing" option of your compiler and try to
- figure out what is really going on. Sometimes you'll be amazed.
-
- But go for the algorithms first. One can waste a lot of time studying
- assembler listings and hand-tuning procedures to gain 10% instead of
- improving the algortihm to gain 50%.
-
- >
- >--
- >
- >Pete
- --
- Niels Ull Jacobsen, Dep. of CS, U of Copenhagen (null@diku.dk)
- Roenne Alle 3 st.th, 2860 Soeborg, Denmark, tel. +45 39 66 39 86
-
-